﻿using System;
using EP.IoC;
using VerifyArgs;
using EP.Caching.Providers;

namespace EP.Caching {
	public sealed class CacheHelper {
		private readonly ICacheProvider _CacheProvider;
		public CacheHelper(ICacheProvider cacheProvider) {
			_CacheProvider = cacheProvider;

			Verify.NotNull(new { _CacheProvider });
		}

		public void Add(string key, object obj) {
			Verify.Args(new { key }).NotNullOrEmpty();

			_CacheProvider.Add(key, obj);
		}

		public object Get(string key) {
			Verify.Args(new { key }).NotNullOrEmpty();

			return _CacheProvider.Get(key);
		}
		public T Get<T>(string key) where T : class, IConvertible {
			Verify.Args(new { key }).NotNullOrEmpty();

			return _CacheProvider.Get<T>(key);
		}

		public void Remove(string key) {
			Verify.Args(new { key }).NotNullOrEmpty();

			_CacheProvider.Remove(key);
		}
	}
}
